'use strict';

module.exports = {
    up: async (queryInterface, Sequelize) => {
        const { STRING, INTEGER, DATE, TEXT, NOW } = Sequelize;

        await queryInterface.createTable(
            'tbl_meeting',
            {
                id: {
                    type: INTEGER,
                    primaryKey: true,
                    autoIncrement: true
                },
                type: {
                    type: INTEGER,
                    allowNull: false,
                    defaultValue: 0
                },
                state: {
                    type: INTEGER,
                    allowNull: false,
                    defaultValue: 1
                },
                title: {
                    type: STRING(32),
                    allowNull: false
                },
                desc: {
                    type: STRING(128),
                    allowNull: false
                },
                image: {
                    type: STRING(128),
                    allowNull: true
                },
                detail: {
                    type: TEXT,
                    allowNull: true,
                },
                release: {
                    type: INTEGER,
                    allowNull: false,
                    defaultValue: 0
                },
                created_at: {
                    type: DATE,
                    allowNull: false,
                    defaultValue: NOW
                },
                updated_at: {
                    type: DATE,
                    allowNull: false,
                    defaultValue: NOW
                }
            },
            {
                charset: 'utf8'
            });

        // queryInterface.addIndex('tbl_member_message', {
        //     name: 'member_chat_index',
        //     fields: ['user_id', 'target_user_id', 'state']
        // });
    },

    down: async (queryInterface, Sequelize) => {
        // await queryInterface.dropTable('tbl_meeting');

        // queryInterface.removeIndex('tbl_member_message', 'member_chat_index');
    }
};
